package com.hrpc;

import com.hrpc.channelHandler.ClientChannelInitializer;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;

/**
 * 提供bootstarp单例
 * TODO 这里会有什么问题？
 */

public class NettyBootStrapInitializer {

    private static final Bootstrap bootstrap=new Bootstrap();
    //静态代码块，防止每次线程来都要做配置
    static {
        NioEventLoopGroup group = new NioEventLoopGroup();
        bootstrap.group(group)
                //选择初始化一个什么样的channel
                .channel(NioSocketChannel.class)
                .handler(new ClientChannelInitializer());
    }
    private NettyBootStrapInitializer(){

    }
    public static Bootstrap getBootstrap(){
        return bootstrap;
    }
}
